package org.igeek.atomqq.widget;

import java.util.List;

import org.igeek.atomqq.AtomQQApplication;
import org.igeek.atomqq.R;
import org.igeek.atomqq.activity.BaseActivity;
import org.igeek.atomqq.domain.Friend;
import org.igeek.atomqq.domain.Group;
import org.igeek.atomqq.net.Response;
import org.igeek.atomqq.task.FaceTask;
import org.igeek.atomqq.task.GroupMemoTask;
import org.igeek.atomqq.task.FaceTask.FaceResponse;
import org.igeek.atomqq.task.GroupMemoTask.GroupMemoResponse;
import org.igeek.atomqq.task.TaskResultListener;
import org.igeek.atomqq.util.Utils;
import org.igeek.atomqq.vo.Chat;
import org.igeek.atomqq.vo.MsgChat;
import org.igeek.atomqq.vo.MsgFriend;
import org.igeek.atomqq.vo.MsgGroup;

import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/** 
 * 好友的单个消息
 * @author <a href="http://hangxin1940.cnblogs.com">hangxin1940@gmail.com</a>
 * @time 2012-2-5 下午06:43:55 
 */
public class FriendMessageItemView extends LinearLayout {
	private BaseActivity context;
	
	private TextView amtvTime;
	private TextView amtvMessage;
	
	
	
	public FriendMessageItemView(BaseActivity context) {
		super(context);
		
		//填充布局
		LayoutInflater infater=(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		infater.inflate(R.layout.widget_message_friend_item, this, true);
		
		this.context=context;
		
		amtvTime=(TextView) findViewById(R.id.widget_message_friend_item_amtvTime);
		amtvMessage=(TextView) findViewById(R.id.widget_message_friend_item_tvMessage);
		
		
		
	}

	public void setMessage(MsgFriend chat) {
		
		String time=String.format("%1$TY-%1$tm-%1$td %1$tT", chat.getTime());
		amtvTime.setText(time);
		List<MsgChat> contents=chat.getMessageContents();
		
		StringBuffer sb=new StringBuffer();
		for(MsgChat msg:contents){
			sb.append(msg.getContent());
		}
		
		amtvMessage.setText(sb);
		
	}



}
